<%@ page import="com.wanshi.utils.Constants" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html  style="background:linear-gradient(to bottom,#fff, #ddd,#fff)">
<head>
    <title>Title</title>

    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        p{
            font-family: "楷体";
            font-size: 16px;
            line-height: 40px;
            font-weight: bold;
            list-style: none;
            overflow: hidden;
            white-space: nowrap; /*设置不换行*/
            text-overflow: ellipsis;
        }
        p img{vertical-align: middle}

        h2,h3{
            display: inline-block;
        }
        .fen{
            color: red;
        }
        .page a{
            width: 50px;
            height: 40px;
            margin: 0px 5px;

            display: inline-block;
            line-height: 40px;
            text-align: center;
            background-color: orangered;
            border-radius: 10px;
            color: white;
            text-decoration: none;
        }

        .page a:hover{
            background-color: aquamarine;
        }
    </style>
</head>
<body style="padding: 20px">

<%
    int num = Constants.PAGE_SIZE;
    pageContext.setAttribute("num",num);
%>

<h2>我的记录</h2>
<%--${fn:length(page.list)}--%>
<h3><a href="${pageContext.request.contextPath}/dati/findTrueByUserId?result=1&pagenum=1" >只看对的</a></h3>
<h3><a href="${pageContext.request.contextPath}/dati/findTrueByUserId?result=0&pagenum=1" >只看错的</a></h3>
<h3><a href="${pageContext.request.contextPath}/dati/myHistory?pagenum=1" >查看所有</a></h3>
<h3 class="fen">&nbsp;&nbsp;总分:${total} </h3><h3 class="fen">&nbsp;&nbsp;我的分数:${fen} </h3>
<h3><a href="${pageContext.request.contextPath}/dati/getScoreListOfCls" >查看其他学生分数</a></h3>
<hr/>
    <c:forEach items="${page.list}" var="r" varStatus="stat">
        <p>${(page.curpage-1)*num + stat.index+1}.
            <c:if test="${r.result == 1}">  <img src="${pageContext.request.contextPath}/img/true.jpg"></c:if>
            <c:if test="${r.result == 0}">  <img src="${pageContext.request.contextPath}/img/false.jpg"></c:if>
            <a href="javaScript:void(0)"  onclick="showContent(this)">显示答案</a>
            <a href="javaScript:void(0)"  onclick="del(this,${r.id})">删除</a>
            <a href="${pageContext.request.contextPath}/dati/findById?id=${r.timu_id}">重做</a>
               <%-- ${fn:replace(r.timu_content,"<BR>"," ")}--%>
                ${r.timu_content}

        </p>
        <span style="display: none">${r.content}</span>
    </c:forEach>

<p class="page"  style="text-align: center;margin-top: 15px;">共${page.count}条记录 共${page.last}页
    <a href="${pageContext.request.contextPath}/dati/findTrueByUserId?pagenum=${page.first}&result=${param.result}">首页</a>
    <a href="${pageContext.request.contextPath}/dati/findTrueByUserId?pagenum=${page.shang}&result=${param.result}">上一页</a>


    <c:forEach begin="${page.startAndEnd[0]}" end="${page.startAndEnd[1]}" step="1" var="shu">
        <c:if test="${page.curpage == shu}">
            ${shu}
        </c:if>
        <c:if test="${page.curpage != shu}">
            <a href="${pageContext.request.contextPath}/dati/findTrueByUserId?pagenum=${shu}&result=${param.result}">${shu}</a>
        </c:if>

    </c:forEach>


    <a href="${pageContext.request.contextPath}/dati/findTrueByUserId?pagenum=${page.next}&result=${param.result}">下一页</a>
    <a href="${pageContext.request.contextPath}/dati/findTrueByUserId?pagenum=${page.last}&result=${param.result}">尾页</a>
</p>

</body>

<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.min.js"></script>

<script>
    function showContent(obj) {
        if($(obj).html() == "显示答案"){
            $(obj).parent().next().show();
            $(obj).html("隐藏答案")
        }else{
            $(obj).parent().next().hide();
            $(obj).html("显示答案")
        }
    }

    function del(obj,id) {
        var isDel = confirm("您将删除答题记录及该记录对应的分数等信息,确定要删除吗?");
        if(isDel){
            $.get("${pageContext.request.contextPath}/dati/delRecord?id="+id, function(result){
                $(obj).parent().remove().siblings().remove();
            });
        }
    }
</script>
</html>
